<a href='https://github.com/angular/angular.js/edit/v1.3.x/src/ng/filter/filters.js?message=docs(json)%3A%20describe%20your%20change...#L492' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this Doc</a>



<a href='https://github.com/angular/angular.js/tree/v1.3.13/src/ng/filter/filters.js#L492' class='view-source pull-right btn btn-primary'>
  <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
</a>


<header class="api-profile-header">
  <h1 class="api-profile-header-heading">json</h1>
  <ol class="api-profile-header-structure naked-list step-list">
    
    <li>
      - filter in module <a href="api/ng">ng</a>
    </li>
  </ol>
</header>



<div class="api-profile-description">
  <p>Allows you to convert a JavaScript object into JSON string.</p>
<p>  This filter is mostly useful for debugging. When using the double curly {{value}} notation
  the binding is automatically converted to JSON.</p>

</div>




<div>
  

  
  <h2>Usage</h2>
  <h3>In HTML Template Binding</h3>
  
    <pre><code>{{ json_expression | json : spacing}}</code></pre>
  

  <h3>In JavaScript</h3>
  <pre><code>$filter(&#39;json&#39;)(object, spacing)</code></pre>

  
<section class="api-section">
  <h3>Arguments</h3>

<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        object
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-object">*</a>
      </td>
      <td>
        <p>Any JavaScript object (including arrays and primitive types) to filter.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        spacing
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-number">number</a>
      </td>
      <td>
        <p>The number of spaces to use per indentation, defaults to 2.</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

</section>
  
  <h3>Returns</h3>
<table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-string">string</a></td>
    <td><p>JSON string.</p>
</td>
  </tr>
</table>


  
  <h2 id="example">Example</h2><p>

<div>
  <a ng-click="openPlunkr('examples/example-example101', $event)" class="btn pull-right">
    <i class="glyphicon glyphicon-edit">&nbsp;</i>
    Edit in Plunker</a>

  <div class="runnable-example"
      path="examples/example-example101">

  
    <div class="runnable-example-file" 
      name="index.html"
      language="html"
      type="html">
      <pre><code>&lt;pre id=&quot;default-spacing&quot;&gt;{{ {&#39;name&#39;:&#39;value&#39;} | json }}&lt;/pre&gt;&#10;&lt;pre id=&quot;custom-spacing&quot;&gt;{{ {&#39;name&#39;:&#39;value&#39;} | json:4 }}&lt;/pre&gt;</code></pre>
    </div>
  
    <div class="runnable-example-file" 
      name="protractor.js"
      type="protractor"
      language="js">
      <pre><code>it(&#39;should jsonify filtered objects&#39;, function() {&#10;  expect(element(by.id(&#39;default-spacing&#39;)).getText()).toMatch(/\{\n  &quot;name&quot;: ?&quot;value&quot;\n}/);&#10;  expect(element(by.id(&#39;custom-spacing&#39;)).getText()).toMatch(/\{\n    &quot;name&quot;: ?&quot;value&quot;\n}/);&#10;});</code></pre>
    </div>
  

    <iframe class="runnable-example-frame" src="examples/example-example101/index.html" name="example-example101"></iframe>
  </div>
</div>


</p>

</div>


